<?php 
	
	ini_set('include_path', '/');
 	include("../bd/conexao/config.php");

    $sql = "SELECT * from areas ORDER BY nome ASC";

	$query     = mysql_query($sql);       //verifica todos as áreas cadastrados
	$resultado = mysql_num_rows($query); //traz o resultado da pesquisa acima

	if ( $resultado > 0 ) {

		echo "<table class='table lista-area'>
		<thead>
			<tr class='GridHeaderStyle'>
				<th> </th>
				<th>Nº</th>				
				<th>Nome</th>							
				<th> </th>		
			</tr>
		</thead>
		<tbody>";

		$i  = 0;
		$id = 1;

 		while($row = mysql_fetch_array($query)) {

 			$i = $i + 1;

			if ($i % 2 == 0) {
				$css_row = 'CRUDGridRowStyle';
			}
			else {
				$css_row = 'CRUDGridAlternatingRowStyle';
			}	

			echo "<tr class='{$css_row}'>";
			echo "<td>" . "<a href=javascript:window.open('editar-area.php?id={$row['id']}','_self');>  <img src='img/editar.png' border='0' id='img-editar_{$row['id']}' data-toggle='tooltip' data-placement='right' title='Editar'> </a>" . "</td>";		
			echo "<td>" . $id  . "</td>";		
  		    echo "<td>" . $row['nome']  . "</td>";  	  		    
  		    echo "<td>" . "<a href='#' id='area_{$row['id']}' value='{$row['id']}'>  <img src='img/deletar.png' border='0' id='img-deletar_{$row['id']}' data-toggle='tooltip' data-placement='right' title='Deletar'> </a>" . "</td>";						      	
		    echo "</tr>";

		    $css_row = 'CRUDGridViewRowStyle';
		    $id += 1;

		}
	
		echo "</tbody>";
		echo "</table>";

	} else {

		echo"		
				<div class='GridNoRow'>	
					<table>
				 		<tr> 
				 			<td class='GridEmptyRowStyle'> Nenhum registro encontrado! </td>
				 		</td>
			 		</table>			
		 		</div>		 		
			";
	}		


?>

